﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XConductor.Domain.Seedwork.Media;

namespace XConductor.Domain.WP8.Media
{
    public class AudioSourceProvider : IAudioSourceProvider
    {
        private bool m_disposed = false;
        private Stream m_stream;

        public AudioSourceProvider(Stream stream, IAudioFormatDescription audioFormat)
        {
            this.m_stream = stream;
            this.AudioFormat = audioFormat;
        }

        public IAudioFormatDescription AudioFormat
        {
            get;
            private set;
        }

        public int Read(byte[] buffer, int offset, int count)
        {
            if (!this.m_disposed)
            {
                return this.m_stream.Read(buffer, offset, count);
            }
            return 0;
        }

        public void Dispose()
        {
            if (!this.m_disposed)
            {
                this.m_stream.Dispose();
            }
        }
    }
}
